<template>
    <view>
        <custom><template #backText>详情</template></custom>
        <view class="bg-gradual-nddyny padding-lr-30 padding-top-40 padding-bottom-80">
            <view class="text-xl text-bold">{{page.title}}</view>
            <view class="flex justify-between align-center margin-top-20 text-white opacity9">
                <view>{{page.author_name}}</view>
                <view>{{page.created_at}}</view>
            </view>
        </view>
        <view class="bg-white round" style="padding:26rpx 30rpx 30rpx; margin-top: -40rpx; border-radius: 40rpx 40rpx 0 0">
            <rich-text :nodes="page.content"></rich-text>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                data: {
                    form: {
                        article_id: 0
                    },
                },
                page: {
                    author_name: '',
                    content: '',
                    created_at: '',
                    title: ''
                }
            }
        },
        onLoad(params) {
            if (!params.article_id) {
                this.$store.commit('userReTo', '/article/list');
                return
            }
            this.data.form.article_id = params.article_id;
            this.pageInit();
        },
        methods: {
            pageInit() {
                this.$api.post(this, {
                    url: '/article/info',
                    success: (Result) => {
                        if (this.$api.form.toast(this, Result)) return;
                        this.page = Result.result;
                    }
                });
            },
        },
    }
</script>
